Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

Help with Script Agent to Create New Documents
~Sven Asafoogenings 01/20/2004 06:00 PM
Domino Designer All Releases Windows 2000


I need help with an agent that I am currently working on. I developed the agent using Script(which I am not experienced with) and I'm not sure how to proceed at this point. The purpose of the agent is the following:

It will be triggered manually to run on selected documents in a view that contains student records/names. It should first display a picklist with a list of courses(from another view) and based on the course(s) selected, create a new form 'Student Record for CEU Course' for each student selected and populate the 'Course Num' field with those courses and finally save and close each document.

The Script that I have written I got from reading the help and utilizing bits and pieces of sample code so I'm not sure if it was done correctly but it does work partially. It will display the picklist of courses but after I select the courses, nothing else happens.....any clues as to what I can change or add to the existing code??????? Any help appreciated. Here is the script I have so far:

Sub Initialize
On Error Goto ErrorHandler
REM get the current database from the session
Dim ses As New NotesSession
Dim db As NotesDatabase
Set db = ses.CurrentDatabase

REM get the unprocessed documents
Dim col As NotesDocumentCollection
Set col = db.UnprocessedDocuments

REM process the unprocessed documents
Dim docToProcess As NotesDocument
For docCount=1 To col.Count
REM get the document in the collection to process
Set docToProcess = col.GetNthDocument(docCount)

Print "Processing document "+Cstr(docCount) + " of "+Cstr(col.Count)

Dim newDoc As New NotesDocument(db)
Dim workspace As New NotesUIWorkspace
Dim picklist As Variant
With newDoc
.Form = "Student Record for CEU Course"
picklist = workspace.PickListStrings(PICKLIST_CUSTOM, True, "dcoirm1ln/DC/USEPA/US", _
"QS\OversightTest.nsf", "Training Events\by Code", "Select a training event", _
"Please select a course this student attended",2)
Call newdoc.FieldSetText("Course_Num", picklist)
.ComputeWithForm True,False
.Save True, True
End With
REM update the doc we just processed so we do not process it again
Call ses.UpdateProcessedDoc(docToProcess)
Exit Sub

Print "Error :: " +Error$+" "+Cstr(Err) + " "+Cstr(Erl)
Exit Sub

End Sub0

End Sub


Go back